import { createStore } from "vuex";
import createPersistedState from "vuex-persistedstate";
export default createStore({
  state: {
    username: null,
    ShoppingDetails: {},
    goodsid: 0,
    address: null,
    tocar: null,
    total: 0,
    coupon: 0,
    states: 0,
  },
  getters: {},
  mutations: {
    setValueDetail(state, goodsid) {
      state.goodsid = goodsid;
    },
    setValue(state, payload) {
      state[payload.key] = payload.value;
    },
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState({
      storage: window.sessionStorage,
      reducer(val) {
        const { coupon, ...rest } = val;
        return rest;
      },
    }),
  ],
});
